import cv2
cap = cv2.VideoCapture("../images/test.mp4") # 打开已有视频
if cap.isOpened():
    print("成功打开视频")
    open, frame = cap.read()
else:
    open = False
while open:
    ret, frame = cap.read()
    if frame is None:
        break
    if ret == True:
        cv2.imshow("video", frame)
        if cv2.waitKey(40) & 0xff == 27:
            break
cap.release()
cv2.destroyAllWindows()